﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Serialization
Imports System.Web.Script.Services
Imports System.Runtime.Serialization


Namespace MyWebservice

    <ScriptService()> _
    <WebService(Namespace:="http://localhost")> _
    Public Class Account
        Inherits System.Web.Services.WebService

        Dim DB As mDB = mDB.GetDB()

        <WebMethod(EnableSession:=False)> _
        Public Function AutoCompleteAccount(ByVal k As String, c As Integer) As List(Of SearchResult)

            Dim accs = DB.TAB.Account.Where("fullname", "like", "%" & k & "%").Limit(30).ToList

            Dim r = New List(Of SearchResult)

            For Each a In accs
                r.Add(New SearchResult With {
                    .id = a.Id, .label = a.Fullname, .value = a.Username, .category = ""
                })
            Next


            Return r


        End Function



    End Class

    Public Class SearchResult

        Public Property id() As String
        Public Property label() As String
        Public Property value() As String
        Public Property category() As String

    End Class

End Namespace
